﻿using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using YduCLB.Front;
using YduCLB.SQL;



public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

	//By Yokit QQ182860914
        Conn Tc = new Conn();
        GList xGList = new GList();
        FCtrl xFctrl = new FCtrl();

        ArrayList Result = new ArrayList();
        string[] aRate = xFctrl.Cvrate();
        string sData = string.Empty;
        string sTem = string.Empty;
        double nPrice = 0;

        try
        {
            SqlDataReader drReader = Tc.ConnDate("select id,title,small_pic,brief,static from " + TableName.db_topics + " where id=1");
            if (drReader.Read())
            {
                sTem = "<a href=\"/promotion/\">{$0}</a>";
                Ft_TopicTi.Text = sTem.Replace("{$0}", drReader["title"].ToString());
                Ft_TopicPic.Text = sTem.Replace("{$0}", "<img src=\"" + drReader["small_pic"].ToString() + "\" alt=\"\" width=\"182\" height=\"125\" />");
                Ft_TopicBrief.Text = drReader["brief"].ToString();
                Ft_TopicLink.Text = sTem.Replace("{$0}", "Detail&gt;&gt;");
            }
            drReader.Close();
            drReader.Dispose();
        }
        catch
        {

        }
        
        sData = string.Empty;
        Result = xGList.get_RecList(TableName.db_product, 1, 3, "is_top=1 order by relea_time desc", new string[] { "id", "static", "title", "was", "price", "small_pic" });
        foreach (string[] aList in Result)
        {
            nPrice = Convert.ToDouble(aList[4]) / Convert.ToDouble(aRate[0]);
            aList[4] = aRate[1] + Math.Round(nPrice, 2).ToString();

            sData = sData + String.Format("<ul><li class=\"i1\"><a href=\"/store/{1}.html\"><img src=\"{5}\" alt=\"\" width=\"75\" height=\"75\" /></a></li><li class=\"i2\"><a href=\"/store/{1}.html\" title=\"{2}\">{2}</a><span>{4}</span></li><li class=\"mclear\"></li></ul>", aList) + "\n";
        }
        Ft_Tsale.Text = sData;


        sData = string.Empty;
        Result = xGList.get_RecList(TableName.db_product, 1, 8, "is_new=1 order by relea_time desc", new string[] { "id", "static", "title", "was", "price", "small_pic" });
        foreach (string[] aList in Result)
        {
            nPrice = Convert.ToDouble(aList[3]) / Convert.ToDouble(aRate[0]);
            aList[3] = aRate[1] + Math.Round(nPrice, 2).ToString();

            nPrice = Convert.ToDouble(aList[4]) / Convert.ToDouble(aRate[0]);
            aList[4] = aRate[1] + Math.Round(nPrice, 2).ToString();

            sData = sData + String.Format("<ul><li class=\"i1\"><a href=\"/store/{1}.html\"><img src=\"{5}\" alt=\"\" width=\"160\" height=\"160\" /></a></li><li class=\"i2\"><a href=\"/store/{1}.html\" title=\"{2}\">{2}</a></li><li class=\"i3\">{3}</li><li class=\"i4\">{4}</li></ul>", aList) + "\n";
        }
        Ft_ProNew.Text = sData;

        sData = string.Empty;
        Result = xGList.get_RecList(TableName.db_product, 1, 8, "is_hot=1 order by relea_time desc", new string[] { "id", "static", "title", "was", "price", "small_pic" });
        foreach (string[] aList in Result)
        {
            nPrice = Convert.ToDouble(aList[3]) / Convert.ToDouble(aRate[0]);
            aList[3] = aRate[1] + Math.Round(nPrice, 2).ToString();

            nPrice = Convert.ToDouble(aList[4]) / Convert.ToDouble(aRate[0]);
            aList[4] = aRate[1] + Math.Round(nPrice, 2).ToString();

            sData = sData + String.Format("<ul><li class=\"i1\"><a href=\"/store/{1}.html\"><img src=\"{5}\" alt=\"\" width=\"160\" height=\"160\" /></a></li><li class=\"i2\"><a href=\"/store/{1}.html\" title=\"{2}\">{2}</a></li><li class=\"i3\">{3}</li><li class=\"i4\">{4}</li></ul>", aList) + "\n";
        }
        Ft_ProHot.Text = sData;
		Ft_PageTitle.Text = "Android Tablet PC, Global Online China Best Android Tablet PC Store, Android Tablet PC from Online Tablet PC Store";
		
        #region
        //ArrayList Result = new ArrayList();
        //string sData = "";
        //Result = xGList.get_RecList(TableName.db_news, 1, 7, "Sort_id=1 order by Publi_time desc", new string[] { "id", "Title", "Publi_time" });
        //foreach (string[] aList in Result)
        //{
        //    aList[1] = "获取列表方案二";
        //    sData = sData + String.Format("<li><a href=\"" + SiteInfo.siteurl + "infor/{0}.html\">{1}</a></li>", aList) + "\n";
        //}
        //Ft_News.Text = sData;
        #endregion
        Tc.CloseConn();
    }
}
